package cn.kgc.controller;

import cn.kgc.pojo.Personnel;
import cn.kgc.pojo.PersonnelJ;
import cn.kgc.service.PersonnelService_jjb;
import cn.kgc.service.Service_szx;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class Controller_szx {

   @Resource
    private Service_szx service_szx;
    @Resource
    private PersonnelService_jjb personnelService_jjb;

    @RequestMapping("/list")
    public String daiBan(){
        return "待办列表";
    }


    @RequestMapping("/selAll")
    @ResponseBody
    public String selAll(@RequestParam String name, @RequestParam String inputtingTime, @RequestParam Integer pageNum, @RequestParam Integer pageSize){
        System.out.println("=======================================================================");
        PageHelper.startPage(pageNum,pageSize);
        Page<Personnel> list = service_szx.selAll(name, inputtingTime);
        PageInfo<Personnel> pageInfo = new PageInfo<>(list);
        return JSON.toJSONStringWithDateFormat(pageInfo,"yyyy-MM-dd");
    }


    @RequestMapping("/人事档案明细2/{personnelid}")
    public String renShiMingXi(Model model,
                               @PathVariable Integer personnelid){
        System.out.println("personnelid = " + personnelid);
        List<PersonnelJ> p = personnelService_jjb.getP(personnelid);
        model.addAttribute("per",p);
        return "人事档案明细2";
    }


    @RequestMapping("/人事档案合2/{personnelid}")
    public String renShiFuHe(Model model,
                             @PathVariable Integer personnelid){
        System.out.println("personnelid = " + personnelid);
        List<PersonnelJ> p = personnelService_jjb.getP(personnelid);
        model.addAttribute("per",p);
        return "/人事档案复合2";
    }
}
